<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: inc.prediction_setting.php 1126 2008-06-09 05:45:04Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
  function jl_pred_setting_show ($sid, $task ,&$my) {
    global $database;
    $prediction_setting = new JLPredictionSetting($database);
    $prediction_setting->load( $sid );
    $query = "SELECT name FROM #__joomleague WHERE id = '".$prediction_setting->project_id."'";
    $database->setQuery($query);
    $settings_name = $database->loadResult();
    /*
    if ($prediction_setting->checked_out && $prediction_setting->checked_out <> $my->id) {
      mosRedirect( JL_ADMIN_COMPONENT_LINK."&adminmode=".JL_ADMIN_MODE, 'This Item has been checked out');
    }
    if ($sid) {
      $prediction_setting->checkout( $my->id );
    }
    */
    $view = JL_ADMIN_TEMPLATE_PATH.'/edit_form_prediction_settings.tpl.php';    

    require JL_ADMIN_TEMPLATE_PATH.'/view.tpl.php'; 
  }
      
  function jl_pred_setting_save ($sid, $task) {
    global $database;
    if ($_POST['tip_joker_limit_select']==0) $_POST['tip_joker_limit']=0;
    $row = new JLPredictionSetting( $database );
    $row->set('id', $sid);
    $row->bind($_POST);
    $row->save($_POST, false);
    $row->load($sid);
    $project = new JoomLeague($database);
    $project->load($row->project_id);
    $project->savePredictionPoints(0,0,$row->project_id);
    if ($task == 'apply')
      mosRedirect( JL_ADMIN_COMPONENT_LINK.'&adminmode='.JL_ADMIN_MODE.'&task=edit&act=prediction_setting&sid='.$sid , 'Data have been Stored');
    elseif ($task ==  'save') {
      mosRedirect( JL_ADMIN_COMPONENT_LINK."&adminmode=".JL_ADMIN_MODE , 'Data have been Stored');
      $row->checkin();
    }
  }
  function jl_pred_setting_cancel ($sid) {
    global $database;
    $row = new JLPredictionSetting( $database );
    $row->set('id', $sid);
	  $row->bind( $_POST );
	  $row->checkin();
	  mosRedirect( JL_ADMIN_COMPONENT_LINK."&adminmode=".JL_ADMIN_MODE );
  }

?>